#include <bits/stdc++.h>

using namespace std;

int n,na,nb,score[5][5]={{0,0,1,1,0},{1,0,0,1,0},{0,1,0,0,1},{0,0,1,0,1},{1,1,0,0,0}};
int main()
{
    scanf("%d%d%d",&n,&na,&nb);
    int a[na]={0},b[nb]={0},cnta=0,cntb=0;;
    for(int i=0;i<na;i++){
        scanf("%d",a+i);
    }
    for(int i=0;i<nb;i++){
        scanf("%d",b+i);
    }
    for(int i=0;i<n;i++){
        if(score[a[i%na]] [b[i%nb]]) cnta++;
        if(score[b[i%nb]] [a[i%na]]) cntb++;
    }
    cout<<cnta<<' '<<cntb;
    return 0;
}
